From e9786f1f44540bcb409e90a25b4bea046083fd2d Mon Sep 17 00:00:00 2001
From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
Date: Fri, 30 Dec 2022 14:33:14 -0700
Subject: [PATCH] use enums for mutually exclusive options in simplify filter
(#966)
* clean up simplify options
* tweak names
* fiddle with simplify test trying to be plaform neutral.
* use stable sort when testing simplify filter
for cross platform matching.
---
reference/simplify_error_crosstrack.gpx | 1853 +++++++++++++++++++++++
reference/simplify_error_length.gpx | 1688 +++++++++++++++++++++
smplrout.cc | 76 +-
smplrout.h | 78 +-
testo.d/simplify.test | 16 +
5 files changed, 3658 insertions(+), 53 deletions(-)
create mode 100644 reference/simplify_error_crosstrack.gpx
create mode 100644 reference/simplify_error_length.gpx
diff --git a/reference/simplify_error_crosstrack.gpx b/reference/simplify_error_crosstrack.gpx
new file mode 100644
index 000000000..7bc664884
--- /dev/null
+++ b/reference/simplify_error_crosstrack.gpx
@@ -0,0 +1,1853 @@
+
+
+
+
+
+ LAP001
+ LAP001
+ LAP001
+
+
+
+
+ 512.800
+
+ 6.823000
+
+
+ 510.200
+
+ 4.681000
+
+
+ 510.200
+
+ 3.937000
+
+
+ 510.200
+
+ 0.817000
+
+
+ 510.200
+
+ 3.088000
+
+
+ 510.200
+
+ 5.925000
+
+
+ 510.200
+
+ 6.637000
+
+
+ 511.400
+
+ 6.363000
+
+
+ 513.200
+
+ 6.396000
+
+
+ 513.200
+
+ 6.376000
+
+
+ 513.200
+
+ 6.140000
+
+
+ 513.600
+
+ 5.769000
+
+
+ 515.200
+
+ 5.993000
+
+
+ 515.600
+
+ 4.891000
+
+
+ 516.400
+
+ 4.226000
+
+
+ 517.200
+
+ 3.469000
+
+
+ 517.200
+
+ 4.833000
+
+
+
+
+ 517.200
+
+ 1.609000
+
+
+ 517.200
+
+ 1.134000
+
+
+ 517.200
+
+ 3.712000
+
+
+ 517.200
+
+ 4.917000
+
+
+ 517.200
+
+ 4.396000
+
+
+ 517.200
+
+ 5.170000
+
+
+ 517.200
+
+ 4.729000
+
+
+ 517.200
+
+ 4.233000
+
+
+ 518.000
+
+ 3.382000
+
+
+ 519.200
+
+ 6.169000
+
+
+ 520.400
+
+ 5.924000
+
+
+ 521.200
+
+ 5.734000
+
+
+ 523.800
+
+ 5.507000
+
+
+ 525.000
+
+ 5.887000
+
+
+ 528.000
+
+ 7.463000
+
+
+ 528.000
+
+ 7.553000
+
+
+ 528.000
+
+ 7.753000
+
+
+ 528.000
+
+ 8.109000
+
+
+ 528.000
+
+ 2.861000
+
+
+ 528.000
+
+ 4.824000
+
+
+ 528.000
+
+ 6.964000
+
+
+ 534.200
+
+ 8.165000
+
+
+ 534.200
+
+ 8.881000
+
+
+ 534.200
+
+ 8.367000
+
+
+ 534.200
+
+ 7.443000
+
+
+ 536.200
+
+ 7.469000
+
+
+ 536.200
+
+ 7.956000
+
+
+ 535.400
+
+ 10.757000
+
+
+ 534.000
+
+ 7.698000
+
+
+ 536.200
+
+ 6.983000
+
+
+ 538.600
+
+ 6.832000
+
+
+ 540.800
+
+ 6.750000
+
+
+ 540.800
+
+ 7.546000
+
+
+ 540.800
+
+ 8.935000
+
+
+ 538.600
+
+ 10.121000
+
+
+ 537.000
+
+ 10.233000
+
+
+ 536.600
+
+ 8.305000
+
+
+ 536.600
+
+ 5.217000
+
+
+ 536.600
+
+ 4.329000
+
+
+ 536.600
+
+ 5.039000
+
+
+ 536.600
+
+ 6.547000
+
+
+ 536.600
+
+ 7.012000
+
+
+ 537.400
+
+ 7.055000
+
+
+ 538.200
+
+ 7.277000
+
+
+ 538.600
+
+ 8.963000
+
+
+ 538.600
+
+ 8.420000
+
+
+ 538.600
+
+ 7.346000
+
+
+ 538.200
+
+ 6.260000
+
+
+ 537.200
+
+ 5.278000
+
+
+ 536.400
+
+ 7.021000
+
+
+ 536.400
+
+ 7.927000
+
+
+ 536.400
+
+ 8.272000
+
+
+ 536.400
+
+ 8.553000
+
+
+ 536.400
+
+ 8.601000
+
+
+ 536.400
+
+ 8.289000
+
+
+ 536.400
+
+ 8.368000
+
+
+ 538.800
+
+ 8.337000
+
+
+ 538.800
+
+ 8.439000
+
+
+ 538.800
+
+ 8.476000
+
+
+ 538.800
+
+ 8.495000
+
+
+ 538.800
+
+ 8.887000
+
+
+ 535.000
+
+ 8.668000
+
+
+ 530.200
+
+ 9.694000
+
+
+ 529.200
+
+ 9.709000
+
+
+ 528.200
+
+ 9.479000
+
+
+ 528.200
+
+ 8.555000
+
+
+ 528.200
+
+ 6.284000
+
+
+ 528.200
+
+ 6.269000
+
+
+ 527.400
+
+ 5.647000
+
+
+ 526.200
+
+ 7.362000
+
+
+ 528.000
+
+ 7.920000
+
+
+ 529.600
+
+ 8.086000
+
+
+ 532.800
+
+ 7.731000
+
+
+ 534.600
+
+ 8.582000
+
+
+ 534.600
+
+ 8.384000
+
+
+ 535.000
+
+ 7.265000
+
+
+ 536.800
+
+ 7.037000
+
+
+ 537.200
+
+ 6.979000
+
+
+ 538.400
+
+ 6.832000
+
+
+ 539.200
+
+ 6.635000
+
+
+ 542.800
+
+ 6.088000
+
+
+ 542.800
+
+ 6.212000
+
+
+ 542.800
+
+ 6.322000
+
+
+ 542.800
+
+ 6.614000
+
+
+ 542.800
+
+ 4.440000
+
+
+ 542.800
+
+ 5.373000
+
+
+ 541.600
+
+ 6.961000
+
+
+ 537.200
+
+ 7.206000
+
+
+ 536.800
+
+ 6.982000
+
+
+ 536.000
+
+ 6.621000
+
+
+ 536.000
+
+ 5.463000
+
+
+ 536.000
+
+ 4.810000
+
+
+ 536.000
+
+ 4.180000
+
+
+ 536.000
+
+ 4.289000
+
+
+ 536.000
+
+ 5.700000
+
+
+ 536.000
+
+ 7.406000
+
+
+ 536.000
+
+ 6.732000
+
+
+ 536.000
+
+ 7.333000
+
+
+ 536.000
+
+ 6.929000
+
+
+ 533.400
+
+ 6.753000
+
+
+ 533.400
+
+ 6.583000
+
+
+ 533.400
+
+ 6.150000
+
+
+ 533.400
+
+ 6.201000
+
+
+ 533.400
+
+ 6.501000
+
+
+ 533.400
+
+ 5.142000
+
+
+ 533.400
+
+ 3.415000
+
+
+ 533.000
+
+ 1.900000
+
+
+ 531.400
+
+ 5.746000
+
+
+ 531.400
+
+ 7.034000
+
+
+ 531.400
+
+ 7.141000
+
+
+ 531.400
+
+ 7.110000
+
+
+ 531.400
+
+ 7.015000
+
+
+ 531.400
+
+ 6.714000
+
+
+ 531.400
+
+ 6.590000
+
+
+ 533.600
+
+ 6.262000
+
+
+ 533.600
+
+ 6.347000
+
+
+ 533.600
+
+ 6.408000
+
+
+ 533.600
+
+ 6.192000
+
+
+ 538.400
+
+ 6.453000
+
+
+ 542.000
+
+ 5.981000
+
+
+
+
+ 542.000
+
+ 1.403000
+
+
+ 542.000
+
+ 1.597000
+
+
+ 542.000
+
+ 1.902000
+
+
+ 542.000
+
+ 0.000000
+
+
+
+
+ 544.000
+
+ 2.290000
+
+
+ 544.000
+
+ 4.167000
+
+
+ 544.000
+
+ 5.402000
+
+
+ 543.200
+
+ 7.379000
+
+
+ 542.000
+
+ 7.587000
+
+
+ 542.000
+
+ 6.804000
+
+
+ 542.000
+
+ 6.545000
+
+
+ 542.800
+
+ 6.379000
+
+
+ 544.000
+
+ 6.600000
+
+
+ 544.000
+
+ 6.309000
+
+
+ 544.000
+
+ 6.790000
+
+
+ 544.000
+
+ 6.709000
+
+
+ 544.000
+
+ 4.810000
+
+
+ 544.000
+
+ 5.492000
+
+
+ 543.000
+
+ 7.660000
+
+
+ 542.200
+
+ 8.258000
+
+
+ 541.600
+
+ 8.561000
+
+
+ 541.600
+
+ 9.160000
+
+
+ 537.400
+
+ 9.487000
+
+
+ 537.400
+
+ 9.509000
+
+
+ 537.400
+
+ 8.400000
+
+
+ 537.400
+
+ 8.791000
+
+
+ 536.600
+
+ 8.933000
+
+
+ 535.400
+
+ 8.761000
+
+
+ 534.600
+
+ 9.202000
+
+
+ 533.200
+
+ 8.724000
+
+
+ 525.400
+
+ 8.764000
+
+
+ 522.200
+
+ 4.602000
+
+
+ 521.800
+
+ 4.790000
+
+
+ 520.000
+
+ 1.070000
+
+
+ 520.000
+
+ 5.040000
+
+
+ 520.000
+
+ 5.242000
+
+
+ 520.000
+
+ 8.234000
+
+
+ 520.000
+
+ 3.098000
+
+
+ 520.000
+
+ 3.994000
+
+
+ 520.000
+
+ 5.026000
+
+
+ 520.000
+
+ 6.505000
+
+
+ 520.000
+
+ 8.095000
+
+
+ 520.000
+
+ 8.113000
+
+
+ 520.000
+
+ 7.418000
+
+
+ 520.000
+
+ 5.753000
+
+
+ 520.000
+
+ 4.639000
+
+
+ 520.000
+
+ 5.552000
+
+
+ 520.000
+
+ 8.079000
+
+
+ 520.000
+
+ 8.282000
+
+
+ 520.000
+
+ 7.536000
+
+
+ 520.000
+
+ 8.335000
+
+
+ 520.000
+
+ 9.137000
+
+
+ 520.000
+
+ 9.141000
+
+
+ 520.400
+
+ 9.091000
+
+
+ 522.000
+
+ 8.963000
+
+
+ 522.000
+
+ 8.642000
+
+
+ 522.000
+
+ 8.443000
+
+
+ 524.000
+
+ 8.976000
+
+
+ 524.000
+
+ 8.923000
+
+
+ 524.000
+
+ 9.112000
+
+
+ 524.000
+
+ 8.736000
+
+
+ 524.000
+
+ 8.775000
+
+
+ 524.000
+
+ 9.174000
+
+
+ 524.000
+
+ 7.944000
+
+
+ 524.000
+
+ 6.455000
+
+
+ 524.000
+
+ 8.553000
+
+
+ 525.000
+
+ 5.705000
+
+
+ 526.400
+
+ 7.737000
+
+
+ 526.400
+
+ 8.019000
+
+
+
+
+ 526.400
+
+ 1.398000
+
+
+ 526.400
+
+ 0.000000
+
+
+
+
+ 526.400
+
+ 3.251000
+
+
+ 528.400
+
+ 7.014000
+
+
+ 528.400
+
+ 6.840000
+
+
+ 528.400
+
+ 6.741000
+
+
+ 528.400
+
+ 7.296000
+
+
+ 528.400
+
+ 7.060000
+
+
+ 528.400
+
+ 6.233000
+
+
+ 528.400
+
+ 6.453000
+
+
+ 528.400
+
+ 7.105000
+
+
+ 528.400
+
+ 6.980000
+
+
+ 528.400
+
+ 3.386000
+
+
+
+
+ 528.400
+
+ 0.648000
+
+
+
+
+ 528.400
+
+ 5.600000
+
+
+ 529.000
+
+ 6.277000
+
+
+ 533.200
+
+ 6.543000
+
+
+ 533.200
+
+ 7.243000
+
+
+ 533.200
+
+ 7.009000
+
+
+ 535.400
+
+ 6.641000
+
+
+ 539.400
+
+ 6.555000
+
+
+ 539.400
+
+ 6.708000
+
+
+ 542.400
+
+ 5.676000
+
+
+ 543.800
+
+ 5.426000
+
+
+ 543.800
+
+ 5.012000
+
+
+ 548.000
+
+ 6.094000
+
+
+ 548.000
+
+ 4.601000
+
+
+ 548.000
+
+ 4.181000
+
+
+ 550.000
+
+ 5.278000
+
+
+ 552.000
+
+ 6.785000
+
+
+ 554.200
+
+ 7.128000
+
+
+ 553.400
+
+ 9.801000
+
+
+ 542.800
+
+ 11.715000
+
+
+ 540.800
+
+ 10.787000
+
+
+ 540.000
+
+ 10.409000
+
+
+ 539.000
+
+ 10.124000
+
+
+ 538.600
+
+ 9.210000
+
+
+ 538.600
+
+ 9.280000
+
+
+ 538.600
+
+ 9.132000
+
+
+ 540.800
+
+ 9.141000
+
+
+ 536.400
+
+ 8.094000
+
+
+ 536.400
+
+ 6.546000
+
+
+ 536.400
+
+ 7.746000
+
+
+ 536.400
+
+ 8.712000
+
+
+ 536.400
+
+ 8.736000
+
+
+ 536.400
+
+ 9.067000
+
+
+ 536.400
+
+ 8.737000
+
+
+ 536.400
+
+ 8.190000
+
+
+ 536.400
+
+ 8.753000
+
+
+ 536.400
+
+ 8.803000
+
+
+ 536.400
+
+ 9.881000
+
+
+ 536.400
+
+ 10.073000
+
+
+ 535.400
+
+ 10.305000
+
+
+ 532.000
+
+ 3.122000
+
+
+ 532.000
+
+ 4.300000
+
+
+ 532.000
+
+ 7.019000
+
+
+ 532.000
+
+ 7.612000
+
+
+ 532.000
+
+ 8.055000
+
+
+ 532.000
+
+ 8.905000
+
+
+ 532.000
+
+ 8.387000
+
+
+ 532.000
+
+ 8.260000
+
+
+ 532.000
+
+ 5.811000
+
+
+ 532.000
+
+ 7.011000
+
+
+ 532.000
+
+ 8.527000
+
+
+ 532.000
+
+ 9.656000
+
+
+ 532.000
+
+ 9.444000
+
+
+ 532.000
+
+ 9.307000
+
+
+ 529.600
+
+ 9.389000
+
+
+ 529.600
+
+ 9.233000
+
+
+ 529.600
+
+ 8.661000
+
+
+ 529.600
+
+ 8.728000
+
+
+ 529.600
+
+ 8.574000
+
+
+ 529.600
+
+ 8.743000
+
+
+ 529.600
+
+ 8.764000
+
+
+ 529.600
+
+ 9.135000
+
+
+ 529.600
+
+ 9.152000
+
+
+ 529.600
+
+ 9.009000
+
+
+ 529.600
+
+ 9.023000
+
+
+ 529.600
+
+ 8.998000
+
+
+ 527.600
+
+ 8.715000
+
+
+ 527.600
+
+ 7.246000
+
+
+ 527.600
+
+ 8.429000
+
+
+ 527.600
+
+ 8.428000
+
+
+ 527.600
+
+ 6.158000
+
+
+ 527.600
+
+ 6.139000
+
+
+ 527.600
+
+ 6.618000
+
+
+ 527.600
+
+ 6.709000
+
+
+ 525.800
+
+ 6.916000
+
+
+ 525.400
+
+ 6.321000
+
+
+ 525.400
+
+ 8.144000
+
+
+ 525.400
+
+ 8.166000
+
+
+ 525.400
+
+ 7.673000
+
+
+ 525.400
+
+ 7.614000
+
+
+ 527.800
+
+ 7.695000
+
+
+ 529.600
+
+ 5.893000
+
+
+ 529.600
+
+ 7.202000
+
+
+ 529.600
+
+ 7.477000
+
+
+ 529.600
+
+ 7.770000
+
+
+ 529.600
+
+ 8.249000
+
+
+ 528.600
+
+ 8.735000
+
+
+ 527.800
+
+ 8.479000
+
+
+ 527.200
+
+ 7.484000
+
+
+ 526.800
+
+ 6.861000
+
+
+ 525.800
+
+ 8.376000
+
+
+ 525.200
+
+ 5.211000
+
+
+ 523.200
+
+ 6.802000
+
+
+ 523.200
+
+ 6.894000
+
+
+ 523.200
+
+ 8.195000
+
+
+ 521.400
+
+ 9.269000
+
+
+ 521.000
+
+ 8.741000
+
+
+ 521.000
+
+ 7.754000
+
+
+ 521.000
+
+ 8.286000
+
+
+ 521.000
+
+ 8.219000
+
+
+ 521.000
+
+ 7.461000
+
+
+ 521.000
+
+ 7.139000
+
+
+ 521.000
+
+ 5.331000
+
+
+ 521.000
+
+ 6.565000
+
+
+ 521.000
+
+ 6.483000
+
+
+ 521.000
+
+ 8.439000
+
+
+ 521.000
+
+ 8.569000
+
+
+ 521.000
+
+ 8.608000
+
+
+ 521.000
+
+ 8.113000
+
+
+ 521.000
+
+ 7.855000
+
+
+ 524.000
+
+ 6.577000
+
+
+ 525.200
+
+ 6.395000
+
+
+ 525.200
+
+ 7.643000
+
+
+ 525.200
+
+ 7.577000
+
+
+ 525.200
+
+ 6.645000
+
+
+ 527.400
+
+ 5.982000
+
+
+ 527.400
+
+ 5.486000
+
+
+ 529.400
+
+ 6.681000
+
+
+ 529.400
+
+ 6.152000
+
+
+ 529.400
+
+ 5.175000
+
+
+ 529.400
+
+ 4.630000
+
+
+ 529.400
+
+ 5.394000
+
+
+ 533.600
+
+ 6.307000
+
+
+ 536.400
+
+ 5.016000
+
+
+ 539.400
+
+ 4.804000
+
+
+ 540.200
+
+ 4.407000
+
+
+ 542.400
+
+ 4.880000
+
+
+ 542.400
+
+ 6.285000
+
+
+ 542.400
+
+ 6.516000
+
+
+ 542.400
+
+ 5.047000
+
+
+ 542.400
+
+ 6.500000
+
+
+ 541.200
+
+ 4.951000
+
+
+ 540.200
+
+ 4.035000
+
+
+ 540.200
+
+ 4.188000
+
+
+ 540.200
+
+ 4.243000
+
+
+ 540.200
+
+ 5.234000
+
+
+ 538.000
+
+ 8.250000
+
+
+ 535.800
+
+ 6.961000
+
+
+ 535.800
+
+ 5.215000
+
+
+ 534.400
+
+ 6.156000
+
+
+ 533.600
+
+ 6.643000
+
+
+ 531.200
+
+ 5.861000
+
+
+ 531.200
+
+ 3.743000
+
+
+ 531.200
+
+ 2.958000
+
+
+ 531.200
+
+ 3.912000
+
+
+ 529.000
+
+ 0.000000
+
+
+
+
diff --git a/reference/simplify_error_length.gpx b/reference/simplify_error_length.gpx
new file mode 100644
index 000000000..4a162239f
--- /dev/null
+++ b/reference/simplify_error_length.gpx
@@ -0,0 +1,1688 @@
+
+
+
+
+
+ LAP001
+ LAP001
+ LAP001
+
+
+
+
+ 512.800
+
+ 6.823000
+
+
+ 510.200
+
+ 4.681000
+
+
+ 510.200
+
+ 3.937000
+
+
+ 510.200
+
+ 0.817000
+
+
+ 510.200
+
+ 3.088000
+
+
+ 511.400
+
+ 6.363000
+
+
+ 513.200
+
+ 6.396000
+
+
+ 513.200
+
+ 6.376000
+
+
+ 513.200
+
+ 6.140000
+
+
+ 513.600
+
+ 5.769000
+
+
+ 515.200
+
+ 5.645000
+
+
+ 515.600
+
+ 4.891000
+
+
+ 516.000
+
+ 4.357000
+
+
+ 517.200
+
+ 1.429000
+
+
+ 517.200
+
+ 1.107000
+
+
+ 517.200
+
+ 0.000000
+
+
+
+
+ 517.200
+
+ 1.609000
+
+
+ 517.200
+
+ 1.667000
+
+
+ 517.200
+
+ 1.134000
+
+
+ 517.200
+
+ 3.712000
+
+
+ 517.200
+
+ 4.530000
+
+
+ 517.200
+
+ 4.917000
+
+
+ 517.200
+
+ 4.396000
+
+
+ 517.200
+
+ 5.170000
+
+
+ 517.200
+
+ 4.729000
+
+
+ 517.200
+
+ 4.233000
+
+
+ 518.000
+
+ 3.382000
+
+
+ 519.200
+
+ 6.169000
+
+
+ 520.400
+
+ 5.924000
+
+
+ 521.200
+
+ 5.734000
+
+
+ 523.800
+
+ 5.507000
+
+
+ 525.000
+
+ 5.887000
+
+
+ 528.000
+
+ 7.553000
+
+
+ 528.000
+
+ 7.753000
+
+
+ 528.000
+
+ 8.109000
+
+
+ 528.000
+
+ 2.861000
+
+
+ 528.000
+
+ 3.488000
+
+
+ 534.200
+
+ 8.881000
+
+
+ 534.200
+
+ 8.367000
+
+
+ 534.200
+
+ 7.443000
+
+
+ 536.200
+
+ 7.469000
+
+
+ 536.200
+
+ 7.956000
+
+
+ 535.400
+
+ 10.757000
+
+
+ 534.000
+
+ 7.698000
+
+
+ 536.200
+
+ 6.983000
+
+
+ 538.600
+
+ 6.832000
+
+
+ 540.800
+
+ 6.750000
+
+
+ 540.800
+
+ 7.546000
+
+
+ 540.800
+
+ 8.935000
+
+
+ 538.600
+
+ 10.121000
+
+
+ 537.000
+
+ 10.233000
+
+
+ 536.600
+
+ 6.682000
+
+
+ 536.600
+
+ 5.217000
+
+
+ 536.600
+
+ 4.329000
+
+
+ 536.600
+
+ 6.547000
+
+
+ 536.600
+
+ 7.012000
+
+
+ 537.400
+
+ 7.055000
+
+
+ 538.200
+
+ 7.277000
+
+
+ 538.600
+
+ 8.963000
+
+
+ 538.600
+
+ 7.346000
+
+
+ 538.200
+
+ 6.260000
+
+
+ 537.600
+
+ 5.257000
+
+
+ 537.200
+
+ 5.278000
+
+
+ 536.400
+
+ 7.361000
+
+
+ 536.400
+
+ 7.927000
+
+
+ 536.400
+
+ 8.233000
+
+
+ 536.400
+
+ 8.553000
+
+
+ 536.400
+
+ 8.601000
+
+
+ 536.400
+
+ 8.289000
+
+
+ 536.400
+
+ 8.368000
+
+
+ 538.800
+
+ 8.337000
+
+
+ 538.800
+
+ 8.439000
+
+
+ 538.800
+
+ 8.476000
+
+
+ 538.800
+
+ 8.495000
+
+
+ 535.000
+
+ 8.668000
+
+
+ 530.200
+
+ 9.694000
+
+
+ 529.200
+
+ 9.709000
+
+
+ 528.200
+
+ 9.479000
+
+
+ 528.200
+
+ 8.555000
+
+
+ 528.200
+
+ 6.284000
+
+
+ 528.200
+
+ 6.269000
+
+
+ 527.400
+
+ 5.647000
+
+
+ 527.000
+
+ 5.113000
+
+
+ 526.200
+
+ 7.362000
+
+
+ 529.600
+
+ 8.086000
+
+
+ 532.800
+
+ 7.731000
+
+
+ 534.600
+
+ 8.582000
+
+
+ 534.600
+
+ 8.384000
+
+
+ 535.000
+
+ 7.265000
+
+
+ 536.800
+
+ 7.037000
+
+
+ 537.200
+
+ 6.979000
+
+
+ 538.400
+
+ 6.832000
+
+
+ 539.200
+
+ 6.635000
+
+
+ 542.800
+
+ 6.088000
+
+
+ 542.800
+
+ 6.212000
+
+
+ 542.800
+
+ 6.322000
+
+
+ 542.800
+
+ 6.614000
+
+
+ 542.800
+
+ 5.814000
+
+
+ 542.800
+
+ 4.440000
+
+
+ 542.800
+
+ 3.249000
+
+
+ 542.800
+
+ 5.373000
+
+
+ 537.200
+
+ 7.206000
+
+
+ 536.800
+
+ 6.982000
+
+
+ 536.000
+
+ 6.621000
+
+
+ 536.000
+
+ 4.180000
+
+
+ 536.000
+
+ 4.289000
+
+
+ 536.000
+
+ 5.700000
+
+
+ 536.000
+
+ 7.406000
+
+
+ 536.000
+
+ 6.732000
+
+
+ 536.000
+
+ 7.333000
+
+
+ 536.000
+
+ 6.929000
+
+
+ 533.400
+
+ 6.753000
+
+
+ 533.400
+
+ 6.583000
+
+
+ 533.400
+
+ 6.150000
+
+
+ 533.400
+
+ 6.201000
+
+
+ 533.400
+
+ 6.501000
+
+
+ 533.400
+
+ 5.142000
+
+
+ 533.400
+
+ 3.415000
+
+
+ 533.000
+
+ 1.900000
+
+
+ 531.400
+
+ 5.746000
+
+
+ 531.400
+
+ 7.034000
+
+
+ 531.400
+
+ 7.141000
+
+
+ 531.400
+
+ 6.714000
+
+
+ 531.400
+
+ 6.590000
+
+
+ 533.600
+
+ 6.262000
+
+
+ 533.600
+
+ 6.347000
+
+
+ 533.600
+
+ 6.408000
+
+
+ 533.600
+
+ 6.192000
+
+
+ 538.400
+
+ 6.453000
+
+
+ 542.000
+
+ 5.981000
+
+
+
+
+ 542.000
+
+ 1.403000
+
+
+ 542.000
+
+ 1.961000
+
+
+ 542.000
+
+ 1.597000
+
+
+ 542.000
+
+ 1.902000
+
+
+ 542.000
+
+ 0.000000
+
+
+
+
+ 544.000
+
+ 2.290000
+
+
+ 544.000
+
+ 4.167000
+
+
+ 544.000
+
+ 5.402000
+
+
+ 543.200
+
+ 7.379000
+
+
+ 542.000
+
+ 7.587000
+
+
+ 543.200
+
+ 6.367000
+
+
+ 544.000
+
+ 6.600000
+
+
+ 544.000
+
+ 6.309000
+
+
+ 544.000
+
+ 6.790000
+
+
+ 544.000
+
+ 6.709000
+
+
+ 544.000
+
+ 4.810000
+
+
+ 544.000
+
+ 5.492000
+
+
+ 543.000
+
+ 7.660000
+
+
+ 542.200
+
+ 8.258000
+
+
+ 541.600
+
+ 8.561000
+
+
+ 541.600
+
+ 9.160000
+
+
+ 537.400
+
+ 9.487000
+
+
+ 537.400
+
+ 9.509000
+
+
+ 537.400
+
+ 8.791000
+
+
+ 535.400
+
+ 8.734000
+
+
+ 533.200
+
+ 8.724000
+
+
+ 525.400
+
+ 8.764000
+
+
+ 522.200
+
+ 4.602000
+
+
+ 521.800
+
+ 4.790000
+
+
+ 520.000
+
+ 1.070000
+
+
+ 520.000
+
+ 5.040000
+
+
+ 520.000
+
+ 5.242000
+
+
+ 520.000
+
+ 3.732000
+
+
+ 520.000
+
+ 3.098000
+
+
+ 520.000
+
+ 3.994000
+
+
+ 520.000
+
+ 5.026000
+
+
+ 520.000
+
+ 8.113000
+
+
+ 520.000
+
+ 7.418000
+
+
+ 520.000
+
+ 5.753000
+
+
+ 520.000
+
+ 4.639000
+
+
+ 520.000
+
+ 5.552000
+
+
+ 520.000
+
+ 8.079000
+
+
+ 520.000
+
+ 8.282000
+
+
+ 520.000
+
+ 7.536000
+
+
+ 520.000
+
+ 8.335000
+
+
+ 520.000
+
+ 9.137000
+
+
+ 520.000
+
+ 9.141000
+
+
+ 521.200
+
+ 8.993000
+
+
+ 522.000
+
+ 8.642000
+
+
+ 522.000
+
+ 8.443000
+
+
+ 524.000
+
+ 8.923000
+
+
+ 524.000
+
+ 9.112000
+
+
+ 524.000
+
+ 8.775000
+
+
+ 524.000
+
+ 7.944000
+
+
+ 524.000
+
+ 6.455000
+
+
+ 526.400
+
+ 8.019000
+
+
+
+
+ 526.400
+
+ 1.398000
+
+
+ 526.400
+
+ 0.000000
+
+
+
+
+ 526.400
+
+ 2.762000
+
+
+ 526.400
+
+ 2.854000
+
+
+ 526.400
+
+ 3.251000
+
+
+ 528.400
+
+ 7.014000
+
+
+ 528.400
+
+ 6.840000
+
+
+ 528.400
+
+ 6.741000
+
+
+ 528.400
+
+ 7.296000
+
+
+ 528.400
+
+ 7.060000
+
+
+ 528.400
+
+ 6.233000
+
+
+ 528.400
+
+ 6.453000
+
+
+ 528.400
+
+ 7.105000
+
+
+ 528.400
+
+ 6.980000
+
+
+ 528.400
+
+ 3.386000
+
+
+
+
+ 528.400
+
+ 0.648000
+
+
+ 528.400
+
+ 0.000000
+
+
+
+
+ 528.400
+
+ 5.600000
+
+
+ 529.000
+
+ 6.277000
+
+
+ 533.200
+
+ 6.543000
+
+
+ 533.200
+
+ 7.243000
+
+
+ 533.200
+
+ 7.009000
+
+
+ 535.400
+
+ 6.641000
+
+
+ 539.400
+
+ 6.555000
+
+
+ 542.400
+
+ 5.676000
+
+
+ 543.800
+
+ 5.426000
+
+
+ 548.000
+
+ 4.601000
+
+
+ 548.000
+
+ 4.181000
+
+
+ 550.000
+
+ 5.278000
+
+
+ 552.000
+
+ 6.785000
+
+
+ 554.200
+
+ 7.128000
+
+
+ 542.800
+
+ 11.715000
+
+
+ 540.800
+
+ 10.787000
+
+
+ 540.000
+
+ 10.409000
+
+
+ 539.000
+
+ 10.124000
+
+
+ 538.600
+
+ 9.210000
+
+
+ 538.600
+
+ 9.132000
+
+
+ 536.400
+
+ 8.094000
+
+
+ 536.400
+
+ 6.546000
+
+
+ 536.400
+
+ 7.746000
+
+
+ 536.400
+
+ 8.712000
+
+
+ 536.400
+
+ 8.736000
+
+
+ 536.400
+
+ 9.067000
+
+
+ 536.400
+
+ 8.190000
+
+
+ 536.400
+
+ 8.753000
+
+
+ 536.400
+
+ 8.803000
+
+
+ 536.400
+
+ 9.881000
+
+
+ 536.400
+
+ 10.073000
+
+
+ 536.400
+
+ 10.149000
+
+
+ 535.400
+
+ 10.305000
+
+
+ 532.000
+
+ 3.122000
+
+
+ 532.000
+
+ 4.300000
+
+
+ 532.000
+
+ 7.019000
+
+
+ 532.000
+
+ 7.612000
+
+
+ 532.000
+
+ 8.055000
+
+
+ 532.000
+
+ 8.387000
+
+
+ 532.000
+
+ 8.260000
+
+
+ 532.000
+
+ 6.990000
+
+
+ 532.000
+
+ 5.776000
+
+
+ 532.000
+
+ 5.811000
+
+
+ 532.000
+
+ 7.011000
+
+
+ 532.000
+
+ 9.656000
+
+
+ 532.000
+
+ 9.444000
+
+
+ 532.000
+
+ 9.307000
+
+
+ 529.600
+
+ 9.389000
+
+
+ 529.600
+
+ 9.233000
+
+
+ 529.600
+
+ 8.661000
+
+
+ 529.600
+
+ 8.574000
+
+
+ 529.600
+
+ 8.743000
+
+
+ 529.600
+
+ 9.135000
+
+
+ 529.600
+
+ 9.152000
+
+
+ 529.600
+
+ 9.009000
+
+
+ 529.600
+
+ 9.023000
+
+
+ 527.600
+
+ 8.715000
+
+
+ 527.600
+
+ 7.246000
+
+
+ 527.600
+
+ 8.429000
+
+
+ 527.600
+
+ 8.428000
+
+
+ 527.600
+
+ 6.158000
+
+
+ 527.600
+
+ 6.618000
+
+
+ 525.800
+
+ 6.916000
+
+
+ 525.400
+
+ 6.321000
+
+
+ 525.400
+
+ 8.166000
+
+
+ 525.400
+
+ 7.673000
+
+
+ 525.400
+
+ 7.614000
+
+
+ 529.600
+
+ 6.457000
+
+
+ 529.600
+
+ 7.477000
+
+
+ 529.600
+
+ 7.770000
+
+
+ 529.600
+
+ 8.249000
+
+
+ 528.600
+
+ 8.735000
+
+
+ 528.200
+
+ 9.047000
+
+
+ 527.800
+
+ 8.479000
+
+
+ 527.200
+
+ 7.484000
+
+
+ 526.800
+
+ 6.861000
+
+
+ 525.800
+
+ 8.376000
+
+
+ 525.200
+
+ 5.211000
+
+
+ 525.200
+
+ 5.051000
+
+
+ 523.200
+
+ 6.802000
+
+
+ 523.200
+
+ 6.894000
+
+
+ 521.000
+
+ 8.219000
+
+
+ 521.000
+
+ 7.461000
+
+
+ 521.000
+
+ 7.139000
+
+
+ 521.000
+
+ 5.331000
+
+
+ 521.000
+
+ 6.565000
+
+
+ 521.000
+
+ 6.483000
+
+
+ 521.000
+
+ 8.439000
+
+
+ 521.000
+
+ 8.608000
+
+
+ 521.000
+
+ 7.855000
+
+
+ 524.000
+
+ 6.577000
+
+
+ 524.400
+
+ 6.523000
+
+
+ 525.200
+
+ 6.395000
+
+
+ 525.200
+
+ 7.577000
+
+
+ 525.200
+
+ 6.645000
+
+
+ 527.400
+
+ 5.982000
+
+
+ 527.400
+
+ 5.486000
+
+
+ 529.400
+
+ 6.681000
+
+
+ 529.400
+
+ 6.152000
+
+
+ 529.400
+
+ 5.175000
+
+
+ 529.400
+
+ 4.630000
+
+
+ 529.400
+
+ 5.394000
+
+
+ 533.600
+
+ 6.307000
+
+
+ 536.400
+
+ 5.016000
+
+
+ 539.400
+
+ 4.804000
+
+
+ 540.200
+
+ 4.605000
+
+
+ 540.200
+
+ 4.407000
+
+
+ 541.600
+
+ 4.724000
+
+
+ 542.400
+
+ 6.285000
+
+
+ 542.400
+
+ 6.516000
+
+
+ 542.400
+
+ 6.389000
+
+
+ 542.400
+
+ 5.047000
+
+
+ 542.400
+
+ 6.500000
+
+
+ 541.200
+
+ 4.951000
+
+
+ 540.600
+
+ 4.097000
+
+
+ 540.200
+
+ 4.188000
+
+
+ 540.200
+
+ 4.243000
+
+
+ 540.200
+
+ 5.234000
+
+
+ 535.800
+
+ 6.961000
+
+
+ 535.800
+
+ 5.215000
+
+
+ 534.400
+
+ 6.156000
+
+
+ 533.600
+
+ 6.643000
+
+
+ 531.200
+
+ 5.861000
+
+
+ 531.200
+
+ 3.743000
+
+
+ 531.200
+
+ 1.853000
+
+
+ 531.200
+
+ 2.958000
+
+
+ 531.200
+
+ 3.912000
+
+
+ 529.400
+
+ 2.303000
+
+
+ 529.000
+
+ 0.000000
+
+
+
+
diff --git a/smplrout.cc b/smplrout.cc
index 1a4814f73..405ab3da6 100644
--- a/smplrout.cc
+++ b/smplrout.cc
@@ -76,7 +76,6 @@ void SimplifyRouteFilter::free_xte(struct xte* xte_rec)
delete xte_rec->intermed;
}
-#define HUGEVAL 2000000000
void SimplifyRouteFilter::routesimple_waypt_pr(const Waypoint* wpt)
{
@@ -101,24 +100,26 @@ void SimplifyRouteFilter::compute_xte(struct xte* xte_rec)
double reslat, reslon;
/* if no previous, this is an endpoint and must be preserved. */
if (!xte_rec->intermed->prev) {
- xte_rec->distance = HUGEVAL;
+ xte_rec->distance = kHugeValue;
return;
}
const Waypoint* wpt1 = xte_rec->intermed->prev->wpt;
/* if no next, this is an endpoint and must be preserved. */
if (!xte_rec->intermed->next) {
- xte_rec->distance = HUGEVAL;
+ xte_rec->distance = kHugeValue;
return;
}
const Waypoint* wpt2 = xte_rec->intermed->next->wpt;
- if (xteopt) {
+ switch (metric) {
+ case metric_t::crosstrack:
xte_rec->distance = radtomiles(linedist(
wpt1->latitude, wpt1->longitude,
wpt2->latitude, wpt2->longitude,
wpt3->latitude, wpt3->longitude));
- } else if (lenopt) {
+ break;
+ case metric_t::length:
xte_rec->distance = radtomiles(
gcdist(wpt1->latitude, wpt1->longitude,
wpt3->latitude, wpt3->longitude) +
@@ -126,14 +127,15 @@ void SimplifyRouteFilter::compute_xte(struct xte* xte_rec)
wpt2->latitude, wpt2->longitude) -
gcdist(wpt1->latitude, wpt1->longitude,
wpt2->latitude, wpt2->longitude));
- } else if (relopt) {
+ break;
+ case metric_t::relative:
if (wpt3->hdop == 0) {
fatal(MYNAME ": relative needs hdop information.\n");
}
// if timestamps exist, distance to interpolated point
if (wpt1->GetCreationTime() != wpt2->GetCreationTime()) {
double frac = (double)(wpt3->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t()) /
- (wpt2->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t());
+ (wpt2->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t());
linepart(wpt1->latitude, wpt1->longitude,
wpt2->latitude, wpt2->longitude,
frac, &reslat, &reslon);
@@ -149,7 +151,7 @@ void SimplifyRouteFilter::compute_xte(struct xte* xte_rec)
// error relative to horizontal precision
xte_rec->distance /= (6 * wpt3->hdop);
// (hdop->meters following to J. Person at )
-
+ break;
}
}
@@ -158,14 +160,14 @@ int SimplifyRouteFilter::compare_xte(const void* a, const void* b)
const auto* xte_a = static_cast(a);
const auto* xte_b = static_cast(b);
- if (HUGEVAL == xte_a->distance) {
- if (HUGEVAL == xte_b->distance) {
+ if (kHugeValue == xte_a->distance) {
+ if (kHugeValue == xte_b->distance) {
return 0;
}
return -1;
}
- if (HUGEVAL == xte_b->distance) {
+ if (kHugeValue == xte_b->distance) {
return 1;
}
@@ -197,7 +199,7 @@ void SimplifyRouteFilter::routesimple_head(const route_head* rte)
totalerror = 0;
/* short-circuit if we already have fewer than the max points */
- if (countopt && count >= rte->rte_waypt_ct()) {
+ if ((limit_basis == limit_basis_t::count) && count >= rte->rte_waypt_ct()) {
return;
}
@@ -245,8 +247,12 @@ void SimplifyRouteFilter::routesimple_tail(const route_head* rte)
auto compare_xte_lambda = [](const xte& a, const xte& b)->bool {
return compare_xte(&a, &b) < 0;
};
- std::sort(xte_recs, xte_recs + xte_count, compare_xte_lambda);
-
+ if (gpsbabel_testmode()) {
+ std::stable_sort(xte_recs, xte_recs + xte_count, compare_xte_lambda);
+ } else {
+ std::sort(xte_recs, xte_recs + xte_count, compare_xte_lambda);
+ }
+
for (i = 0; i < xte_count; i++) {
xte_recs[i].intermed->xte_rec = xte_recs+i;
@@ -261,19 +267,24 @@ void SimplifyRouteFilter::routesimple_tail(const route_head* rte)
}
/* while we still have too many records... */
- while ((xte_count) && ((countopt && count < xte_count) || (erroropt && totalerror < error))) {
+ while ((xte_count) &&
+ (((limit_basis == limit_basis_t::count) && (count < xte_count)) ||
+ ((limit_basis == limit_basis_t::error) && (totalerror < error)))) {
i = xte_count - 1;
/* remove the record with the lowest XTE */
- if (erroropt) {
- if (xteopt || relopt) {
+ if (limit_basis == limit_basis_t::error) {
+ switch (metric) {
+ case metric_t::crosstrack:
+ case metric_t::relative:
if (i > 1) {
totalerror = xte_recs[i-1].distance;
} else {
totalerror = xte_recs[i].distance;
}
- }
- if (lenopt) {
+ break;
+ case metric_t::length:
totalerror += xte_recs[i].distance;
+ break;
}
}
(*waypt_del_fnp)(const_cast(rte),
@@ -320,20 +331,29 @@ void SimplifyRouteFilter::init()
{
count = 0;
- if (!!countopt == !!erroropt) {
+ if (!countopt && erroropt) {
+ limit_basis = limit_basis_t::error;
+ } else if (countopt && !erroropt) {
+ limit_basis = limit_basis_t::count;
+ } else {
fatal(MYNAME ": You must specify either count or error, but not both.\n");
}
- if ((!!xteopt + !!lenopt + !!relopt) > 1) {
+
+ if (!lenopt && !relopt) {
+ metric = metric_t::crosstrack; /* default */
+ } else if (!xteopt && lenopt && !relopt) {
+ metric = metric_t::length;
+ } else if (!xteopt && !lenopt && relopt) {
+ metric = metric_t::relative;
+ } else {
fatal(MYNAME ": You may specify only one of crosstrack, length, or relative.\n");
}
- if (!xteopt && !lenopt && !relopt) {
- xteopt = (char*) "";
- }
- if (countopt) {
+ switch (limit_basis) {
+ case limit_basis_t::count:
count = strtol(countopt, nullptr, 10);
- }
- if (erroropt) {
+ break;
+ case limit_basis_t::error: {
int res = parse_distance(erroropt, &error, 1.0, MYNAME);
if (res == 0) {
error = 0;
@@ -341,6 +361,8 @@ void SimplifyRouteFilter::init()
error = METERS_TO_MILES(error);
}
}
+ break;
+ }
}
#endif // FILTERS_ENABLED
diff --git a/smplrout.h b/smplrout.h
index 2386432ca..d847371d2 100644
--- a/smplrout.h
+++ b/smplrout.h
@@ -59,16 +59,21 @@
#ifndef SMPLROUT_H_INCLUDED_
#define SMPLROUT_H_INCLUDED_
-#include // for QVector
+#include // for QString
+#include // for QVector
#include "defs.h" // for route_head (ptr only), Waypoint (ptr only), ARGT...
#include "filter.h" // for Filter
+
#if FILTERS_ENABLED
class SimplifyRouteFilter:public Filter
{
public:
+
+ /* Member Functions */
+
QVector* get_args() override
{
return &args;
@@ -78,16 +83,61 @@ public:
private:
+ /* Types */
+
+ enum class limit_basis_t {count, error};
+ enum class metric_t {crosstrack, length, relative};
+
+ struct xte_intermed;
+
+ struct xte {
+ double distance{0.0};
+ struct xte_intermed* intermed {
+ nullptr
+ };
+ };
+
+ struct xte_intermed {
+ struct xte* xte_rec {
+ nullptr
+ };
+ struct xte_intermed* next {
+ nullptr
+ };
+ struct xte_intermed* prev {
+ nullptr
+ };
+ const Waypoint* wpt{nullptr};
+ };
+
+ /* Constants */
+
+ static constexpr double kHugeValue = 2000000000;
+
+ /* Member Functions */
+
+ static void free_xte(struct xte* xte_rec);
+ void routesimple_waypt_pr(const Waypoint* wpt);
+ void compute_xte(struct xte* xte_rec);
+ static int compare_xte(const void* a, const void* b);
+ void routesimple_head(const route_head* rte);
+ void shuffle_xte(struct xte* xte_rec);
+ void routesimple_tail(const route_head* rte);
+
+ /* Data Members */
+
int count = 0;
double totalerror = 0;
double error = 0;
+ limit_basis_t limit_basis{limit_basis_t::error};
+ metric_t metric{metric_t::crosstrack};
char* countopt = nullptr;
char* erroropt = nullptr;
char* xteopt = nullptr;
char* lenopt = nullptr;
char* relopt = nullptr;
- void (*waypt_del_fnp)(route_head* rte, Waypoint* wpt){};
+ void (*waypt_del_fnp)(route_head* rte, Waypoint* wpt) {};
QVector args = {
{
@@ -112,34 +162,10 @@ private:
},
};
- struct xte_intermed;
-
- struct xte {
- double distance{0.0};
- struct xte_intermed* intermed{nullptr};
- };
-
- struct xte_intermed {
- struct xte* xte_rec{nullptr};
- struct xte_intermed* next{nullptr};
- struct xte_intermed* prev{nullptr};
- const Waypoint* wpt{nullptr};
- };
-
- static void free_xte(struct xte* xte_rec);
-
struct xte_intermed* tmpprev = nullptr;
int xte_count = 0;
const route_head* cur_rte = nullptr;
struct xte* xte_recs = nullptr;
-
- void routesimple_waypt_pr(const Waypoint* wpt);
- void compute_xte(struct xte* xte_rec);
- static int compare_xte(const void* a, const void* b);
- void routesimple_head(const route_head* rte);
- void shuffle_xte(struct xte* xte_rec);
- void routesimple_tail(const route_head* rte);
-
};
#endif // FILTERS_ENABLED
diff --git a/testo.d/simplify.test b/testo.d/simplify.test
index 2539e4415..7771702bb 100644
--- a/testo.d/simplify.test
+++ b/testo.d/simplify.test
@@ -7,3 +7,19 @@ gpsbabel -r -i gpx -f ${REFERENCE}/route/route.gpx \
-o arc -F ${TMPDIR}/simplify.txt
compare ${REFERENCE}/simplify_output.txt ${TMPDIR}/simplify.txt
+gpsbabel -i gpx -f ${REFERENCE}/track/garmin-edge-800-output.gpx \
+ -x simplify,error=2m,crosstrack \
+ -o gpx -F ${TMPDIR}/simplify_error_crosstrack.gpx
+compare ${REFERENCE}/simplify_error_crosstrack.gpx ${TMPDIR}/simplify_error_crosstrack.gpx
+
+# verify the default matches crosstrack
+gpsbabel -i gpx -f ${REFERENCE}/track/garmin-edge-800-output.gpx \
+ -x simplify,error=2m \
+ -o gpx -F ${TMPDIR}/simplify_error.gpx
+compare ${REFERENCE}/simplify_error_crosstrack.gpx ${TMPDIR}/simplify_error.gpx
+
+gpsbabel -i gpx -f ${REFERENCE}/track/garmin-edge-800-output.gpx \
+ -x simplify,error=1000m,length \
+ -o gpx -F ${TMPDIR}/simplify_error_length.gpx
+compare ${REFERENCE}/simplify_error_length.gpx ${TMPDIR}/simplify_error_length.gpx
+
--
2.30.2